﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace Loader
{
    /// <summary>
    /// Interaction logic for exeItem.xaml
    /// </summary>
    public partial class exeItem : UserControl
    {
        ServiceReference2.Service1Client svc = new ServiceReference2.Service1Client();
        public StackPanel spSettings = new StackPanel();
        public ServiceReference2.EXE selectedExe;
        public exeItem(ServiceReference2.EXE exe)
        {
            this.InitializeComponent();
            selectedExe = exe;
            lbl_exeDescription.Text = exe.Description;
            lbl_exeName.Text = exe.Name;
            #region not in used atm
            //spSettings.Orientation = Orientation.Horizontal;
            //if (exe.CustKey != null && exe.CustKey.Count != 0)
            //{
            //    try
            //    {
            //        //lbl_setting.Visibility = Visibility.Visible;
            //        foreach (string key in exe.CustKey)
            //        {
            //            StackPanel stackpanel = new StackPanel();
            //            stackpanel.Margin = new Thickness(0, 2, 0, 2);
            //            stackpanel.Orientation = Orientation.Horizontal;
            //            TextBlock textblock = new TextBlock();

            //            BrushConverter brush = new BrushConverter();
            //            textblock.Foreground = (Brush)brush.ConvertFromString("#FF000000");
            //            textblock.Text = key;
            //            TextBlock space = new TextBlock();
            //            space.Text = " : ";
            //            space.Foreground = (Brush)brush.ConvertFromString("#FF000000");
            //            textblock.FontWeight = FontWeights.Bold;
            //            TextBox textbox = new TextBox();
            //            textbox.HorizontalAlignment = HorizontalAlignment.Stretch;
            //            textbox.Margin = new Thickness(0, 0, 0, 0);
            //            textbox.Width = 100;
            //            if (!lbl_exeName.Text.Equals("Asteroids"))
            //            {
            //                if (exe.SettingsList != null)
            //                {
            //                    foreach (KeyValuePair<string, string> temp in exe.SettingsList)
            //                    {
            //                        if (temp.Key.Equals(key))
            //                        {
            //                            textbox.Text = temp.Value;
            //                        }
            //                    }
            //                }
            //                stackpanel.Children.Add(textblock);
            //                stackpanel.Children.Add(space);
            //                stackpanel.Children.Add(textbox);
            //                panel_key.Children.Add(stackpanel);
            //            }
            //            else
            //            {
            //                List<double> angle = new List<double>();
            //                angle = svc.getLatestAngle(10, 1, 4, "");
            //                double x = angle[0] + 5;

            //                if (x > 175)
            //                {
            //                    x = angle[0];
            //                }

            //                double y = angle[1] + 5;

            //                if (y < 4)
            //                {
            //                    y = angle[0];
            //                }
            //                angle.Clear();
            //                if (key == "Targeted Max Angle")
            //                {
            //                    textbox.Text = x.ToString();
            //                }
            //                else if (key == "Targeted Min Angle")
            //                {
            //                    textbox.Text = y.ToString();
            //                }
            //                else
            //                {
            //                    textbox.Text = "300";
            //                }

            //                //stackpanel.Children.Add(textblock);
            //                //stackpanel.Children.Add(space);
            //                //stackpanel.Children.Add(textbox);
            //                spSettings.Children.Add(textblock);
            //                spSettings.Children.Add(space);
            //                spSettings.Children.Add(textbox);
            //                //panel_key.Children.Add(stackpanel);
            //            }
            //        }
            //    }
            //    catch (Exception) { }
            //}
            //else
            //{
            //    //tohide.Visibility = Visibility.Visible;
            //}
            #endregion
          
        }

        bool hide = false;

        private void lbl_setting_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (hide == false)
            {
                //start loading
                Storyboard loading1;
                loading1 = (Storyboard)FindResource("toshow");
                loading1.Begin();
                hide = true;
            }
            else
            {
                //start loading
                Storyboard loading1;
                loading1 = (Storyboard)FindResource("tohide");
                loading1.Begin();
                hide = false;
            }
        }
    }
}